<?php

class Create_Jijaf_Users_Has_Jijaf_Groups {

	/**
	 * Make changes to the database.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('jijaf_users_has_jijaf_groups', function($table) {
            $table->increments('id');
            $table->integer('group_id')->unsigned();
            $table->foreign('group_id')->references('id')
                        ->on('jijaf_groups')
                        ->on_delete('restrict')
                        ->on_update('cascade');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')
                        ->on('jijaf_users')
                        ->on_delete('restrict')
                        ->on_update('cascade');
            $table->timestamps();
        });

        DB::table('jijaf_users_has_jijaf_groups')->insert(array(
            'user_id'      => 1,
            'group_id'     => 1,
        ));
	}

	/**
	 * Revert the changes to the database.
	 *
	 * @return void
	 */
	public function down()
	{
        Schema::drop('jijaf_users_has_jijaf_groups');
	}

}
